﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NetalBase.Base
{
	public abstract class StateBase<TEventPoint, TDataPoint> : IStateBase
	{
		#region Public members
		public IAutomatonBase Automaton { get; set; }

		public TDataPoint DataPoint { get; set; }

		virtual public void StateAction(TEventPoint eventPoint)
		{
		}
		#endregion

		#region Protected members
		protected void LogAction(string message)
		{
			Log.Logger.Write(Automaton.StringId + " " + message);
		}

		protected void _(Action action)
		{
			Automaton.Events2RelatedAutomata.Add(action);
		}

		protected void async(Action action)
		{
			Task.Factory.StartNew(action);
		}
		#endregion

		#region IStateBase Members
		public string StateName { get { return GetType().Name; } }
		#endregion
	}
}
